import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

import javax.swing.JPanel;


public class PaintPanel extends JPanel {
	
	private int pointCount = 0; // count number of points
	
	private Point[] points = new Point[100]; // tablica punktow POINT
	
	public PaintPanel() {
		addMouseMotionListener(
				new MouseMotionAdapter() {
					
					@Override
					public void mouseDragged(MouseEvent event) {
						if(pointCount < points.length) {
							points[pointCount] = event.getPoint();
							++pointCount;
							repaint();// repaint JFrame
						}
					}
				}
				);
	}
	
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		// draw allPoints in array
		for(int i = 0 ; i < pointCount; i++) {
			g.fillOval(points[i].x, points[i].y, 4, 4);
		}
	}

}
